package com.shenmazong.demo1907amongo.controller;

import com.shenmazong.demo1907amongo.pojo.TbBlog;
import com.shenmazong.demo1907amongo.service.ITbBlogService;
import com.shenmazong.demo1907amongo.utils.ResultResponse;
import com.shenmazong.demo1907amongo.vo.IdVo;
import com.shenmazong.demo1907amongo.vo.KeyWordVo;
import com.shenmazong.demo1907amongo.vo.PageVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2021/12/14 15:42
 */

@RestController
@Slf4j
@CrossOrigin
@RequestMapping(value = "/blog")
public class TbBlogController {

    @Autowired
    ITbBlogService iTbBlogService;

    @PostMapping(value = "/list")
    public ResultResponse list(@RequestBody PageVo pageVo) {
        return iTbBlogService.list(pageVo);
    }

    @PostMapping(value = "/del")
    public ResultResponse del(@RequestBody IdVo idVo) {
        return iTbBlogService.del(idVo.getId());
    }

    @PostMapping(value = "/add")
    public ResultResponse add(@RequestBody TbBlog tbBlog) {
        return iTbBlogService.add(tbBlog);
    }

    @PostMapping(value = "/getBlogById")
    public ResultResponse getBlogById(@RequestBody IdVo idVo) {
        return iTbBlogService.getBlogById(idVo.getId());
    }

    @PostMapping(value = "/updateBlogById")
    public ResultResponse updateBlogById(@RequestBody TbBlog tbBlog) {
        return iTbBlogService.updateBlogById(tbBlog);
    }

    @PostMapping(value = "/getBlogByKeyword")
    public ResultResponse getBlogByKeyword(@RequestBody KeyWordVo keyWord) {
        return iTbBlogService.getBlogByKeyword(keyWord);
    }
}
